package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.GoodsSkuImage;
import com.micro.modual.extension.GoodsSkuImageExtension;
import com.micro.modual.mapper.GoodsSkuImageMapper;
import com.micro.modual.model.bo.goodsskuimage.GoodsSkuImageBO;
import com.micro.modual.service.GoodsSkuImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>商品sku图片表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("goodsSkuImageService")
public class GoodsSkuImageServiceImpl extends AbstractBasicsServiceImpl<GoodsSkuImage,Long> implements GoodsSkuImageService {

    @Autowired
    private GoodsSkuImageMapper goodsSkuImageMapper;

    /**
     * <h2>新增商品sku图片表详情</h2>
     * @param goodsSkuImageBO {@link GoodsSkuImageBO} 商品sku图片表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addGoodsSkuImage(GoodsSkuImageBO goodsSkuImageBO) {
        GoodsSkuImage goodsSkuImage = GoodsSkuImageExtension.converAddGoodsSkuImage(goodsSkuImageBO);
        goodsSkuImageMapper.insertSelective(goodsSkuImage);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改商品sku图片表详情</h2>
     * @param goodsSkuImageBO  {@link GoodsSkuImageBO} 商品sku图片表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editGoodsSkuImage(GoodsSkuImageBO goodsSkuImageBO) {
        GoodsSkuImage goodsSkuImage = GoodsSkuImageExtension.converEditGoodsSkuImage(goodsSkuImageBO);
        goodsSkuImageMapper.updateByPrimaryKeySelective(goodsSkuImage);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除商品sku图片表信息</h2>
     * @param id  商品sku图片表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteGoodsSkuImage(Long id) {
        goodsSkuImageMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
